class Solution {
public:
    int halveArray(vector<int>& nums) {
        int k=0;
        double a1=0;
        double a2=0;
        priority_queue<double> pq;
        for(auto& ch:nums)
        {
            a1+=ch;
            a2+=ch;
            pq.push(ch);
        }
        a1/=2;
        while(a2>a1)
        {
            double tmp=pq.top()/2;
            pq.pop();
            pq.push(tmp);
            a2-=tmp;
            k++;
        }
        return k;
    }
};
